package com.yidu.t299.service.ljc.impl;
import com.yidu.t299.dao.ljc.GoodscheckMapper;
import com.yidu.t299.domain.ljc.Goodscheck;
import com.yidu.t299.service.ljc.GoodscheckBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/20 8:50
 */
@Service
@Transactional
public class GoodscheckBizImpl implements GoodscheckBiz {
    @Autowired
    private GoodscheckMapper goodscheckMapper;


    @Override
    public int deleteByPrimaryKey(Integer checkId) {
        return goodscheckMapper.deleteByPrimaryKey(checkId);
    }

    @Override
    public int insert(Goodscheck record) {
        return goodscheckMapper.insert(record);
    }

    @Override
    public Goodscheck selectByPrimaryKey(Integer checkId) {
        return goodscheckMapper.selectByPrimaryKey(checkId);
    }

    @Override
    public List<Goodscheck> selectByPage(int rows, int page, String condition) {
        return goodscheckMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return goodscheckMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(Goodscheck record) {
        return goodscheckMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(Goodscheck record) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        // 如果校区对象为空，则直接返回空条件字符串
        if (record == null) {
            return condition;
        }
        // 如果校区编号不为空(如果是基本类型就直接判断!=0)
        if (record.getCheckId() != null) {
            condition += " and goods_check_id = " + record.getCheckId();
        }
        // 如果校区名称不为空
        if (record.getInName() != null && record.getInName().trim().length() != 0) {
            condition += " and in_name like '%" + record.getInName() + "%'";
        }

        if (record.getBookerId() != null && record.getBookerId().trim().length() != 0) {
            condition += " and booker_id = " + record.getBookerId();
        }

        if (record.getCheckDate() != null && record.getCheckDate().trim().length() != 0) {
            condition += " and goods_check_date like '%" + record.getCheckDate() + "%'";
        }

        if (record.getMent() != null && record.getMent().trim().length() != 0) {
            condition += " and ment = " + record.getMent() + "%'";
        }

        // 返回条件字符串
        return condition;
    }
}
